<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Autotest::Rspec</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Autotest::Rspec</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/vendor/plugins/rspec/lib/autotest/rspec_rb.html">
                vendor/plugins/rspec/lib/autotest/rspec.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../Autotest.html">
                Autotest
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000009">add_options_if_present</a>&nbsp;&nbsp;
      <a href="#M000007">consolidate_failures</a>&nbsp;&nbsp;
      <a href="#M000005">failed_results</a>&nbsp;&nbsp;
      <a href="#M000006">handle_results</a>&nbsp;&nbsp;
      <a href="#M000008">make_test_cmd</a>&nbsp;&nbsp;
      <a href="#M000010">spec_command</a>&nbsp;&nbsp;
      <a href="#M000011">spec_commands</a>&nbsp;&nbsp;
      <a href="#M000004">specs_for_file</a>&nbsp;&nbsp;
      <a href="#M000003">tests_for_file</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000009" class="method-detail">
        <a name="M000009"></a>

        <div class="method-heading">
          <a href="#M000009" class="method-signature">
          <span class="method-name">add_options_if_present</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000009-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/autotest/rspec.rb, line 65</span>
65:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_options_if_present</span>
66:     <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-value str">&quot;spec/spec.opts&quot;</span>) <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;-O spec/spec.opts &quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;&quot;</span>
67:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000007" class="method-detail">
        <a name="M000007"></a>

        <div class="method-heading">
          <a href="#M000007" class="method-signature">
          <span class="method-name">consolidate_failures</span><span class="method-args">(failed)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000007-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/autotest/rspec.rb, line 48</span>
48:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">consolidate_failures</span>(<span class="ruby-identifier">failed</span>)
49:     <span class="ruby-identifier">filters</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = [] }
50:     <span class="ruby-identifier">failed</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">spec</span>, <span class="ruby-identifier">failed_trace</span><span class="ruby-operator">|</span>
51:       <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">select</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/spec\//</span>}.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
52:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">failed_trace</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">f</span>)
53:           <span class="ruby-identifier">filters</span>[<span class="ruby-identifier">f</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">spec</span>
54:           <span class="ruby-keyword kw">break</span>
55:         <span class="ruby-keyword kw">end</span>
56:       <span class="ruby-keyword kw">end</span>
57:     <span class="ruby-keyword kw">end</span>
58:     <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">filters</span>
59:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000005" class="method-detail">
        <a name="M000005"></a>

        <div class="method-heading">
          <a href="#M000005" class="method-signature">
          <span class="method-name">failed_results</span><span class="method-args">(results)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000005-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/autotest/rspec.rb, line 34</span>
34:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">failed_results</span>(<span class="ruby-identifier">results</span>)
35:     <span class="ruby-identifier">results</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/</span><span class="ruby-identifier">m</span>)
36:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000006" class="method-detail">
        <a name="M000006"></a>

        <div class="method-heading">
          <a href="#M000006" class="method-signature">
          <span class="method-name">handle_results</span><span class="method-args">(results)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000006-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/autotest/rspec.rb, line 38</span>
38:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handle_results</span>(<span class="ruby-identifier">results</span>)
39:     <span class="ruby-ivar">@files_to_test</span> = <span class="ruby-identifier">consolidate_failures</span> <span class="ruby-identifier">failed_results</span>(<span class="ruby-identifier">results</span>)
40:     <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@files_to_test</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword kw">then</span>
41:       <span class="ruby-identifier">hook</span> <span class="ruby-identifier">:red</span>
42:     <span class="ruby-keyword kw">else</span>
43:       <span class="ruby-identifier">hook</span> <span class="ruby-identifier">:green</span>
44:     <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">$TESTING</span>
45:     <span class="ruby-ivar">@tainted</span> = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@files_to_test</span>.<span class="ruby-identifier">empty?</span>
46:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000008" class="method-detail">
        <a name="M000008"></a>

        <div class="method-heading">
          <a href="#M000008" class="method-signature">
          <span class="method-name">make_test_cmd</span><span class="method-args">(files_to_test)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000008-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/autotest/rspec.rb, line 61</span>
61:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">make_test_cmd</span>(<span class="ruby-identifier">files_to_test</span>)
62:     <span class="ruby-keyword kw">return</span> <span class="ruby-node">&quot;#{ruby} -S #{@spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}&quot;</span>
63:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000010" class="method-detail">
        <a name="M000010"></a>

        <div class="method-heading">
          <a href="#M000010" class="method-signature">
          <span class="method-name">spec_command</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Finds the proper spec command to use. Precendence is set in the
lazily-evaluated method <a href="Rspec.html#M000011">spec_commands</a>.
Alias + Override that in ~/.autotest to provide a different spec command
then the default paths provided.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000010-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/autotest/rspec.rb, line 73</span>
73:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">spec_command</span>
74:     <span class="ruby-identifier">spec_commands</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">command</span><span class="ruby-operator">|</span>
75:       <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">command</span>)
76:         <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@alt_separator</span> <span class="ruby-operator">?</span> (<span class="ruby-identifier">command</span>.<span class="ruby-identifier">gsub</span> <span class="ruby-ivar">@separator</span>, <span class="ruby-ivar">@alt_separator</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">command</span>
77:       <span class="ruby-keyword kw">end</span>
78:     <span class="ruby-keyword kw">end</span>
79:     
80:     <span class="ruby-identifier">raise</span> <span class="ruby-constant">RspecCommandError</span>, <span class="ruby-value str">&quot;No spec command could be found!&quot;</span>
81:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000011" class="method-detail">
        <a name="M000011"></a>

        <div class="method-heading">
          <a href="#M000011" class="method-signature">
          <span class="method-name">spec_commands</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
<a href="../Autotest.html">Autotest</a> will look for spec commands in the
following locations, in this order:
</p>
<pre>
  * bin/spec
  * default spec bin/loader installed in Rubygems
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000011-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/autotest/rspec.rb, line 88</span>
88:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">spec_commands</span>
89:     [
90:       <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">'bin'</span>, <span class="ruby-value str">'spec'</span>),
91:       <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">Config</span><span class="ruby-operator">::</span><span class="ruby-constant">CONFIG</span>[<span class="ruby-value str">'bindir'</span>], <span class="ruby-value str">'spec'</span>)
92:     ]
93:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000004" class="method-detail">
        <a name="M000004"></a>

        <div class="method-heading">
          <span class="method-name">specs_for_file</span><span class="method-args">(filename)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Rspec.html#M000003">tests_for_file</a>
</p>
        </div>
      </div>

      <div id="method-M000003" class="method-detail">
        <a name="M000003"></a>

        <div class="method-heading">
          <a href="#M000003" class="method-signature">
          <span class="method-name">tests_for_file</span><span class="method-args">(filename)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000003-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/autotest/rspec.rb, line 28</span>
28:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tests_for_file</span>(<span class="ruby-identifier">filename</span>)
29:     <span class="ruby-keyword kw">super</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">f</span> }
30:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>